﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Bll;
using Help;
using Model;

namespace Myproject.BSM.Ashx.PcBase
{
    /// <summary>
    /// JoinEdit 的摘要说明
    /// </summary>
    public class JoinEdit : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string id = context.Request.Params["pc_base_JoinEdit_joinID"].Trim();
            string title = context.Request.Params["pc_base_JoinEdit_title"].Trim();
            string number = context.Request.Params["pc_base_JoinEdit_number"].Trim();
            string money = context.Request.Params["pc_base_JoinEdit_money"].Trim();
            string text = context.Request.Params["pc_base_JoinEdit_text"].Trim();
            if (id == "0")
            {
                JoinModel model = new JoinModel();
                model.title = title;
                model.unmber =int.Parse(number);
                model.money = money;
                model.text = text;

                if (new JoinBLL().Add(model)>0)
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(200, "新增招聘成功！", "pc_base_joinList", "", "", true, "", ""));
                }
                else
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "新增招聘失败！", "pc_base_joinList", "", "", true, "", ""));
                }
            }
            else
            {
                JoinModel model = new JoinBLL().GetModel(Int32.Parse(id));
                model.title = title;
                model.unmber = int.Parse(number);
                model.money = money;
                model.text = text;
                if (new JoinBLL().Update(model))
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(200, "修改招聘成功！", "pc_base_joinList", "", "", true, "", ""));
                }
                else
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "修改招聘失败！", "pc_base_joinList", "", "", true, "", ""));
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}